package com.xiaolin.web.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

/**
 * @ClassName HelloFilter
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/28
 * @Version 1.0
 */
@Component
public class HelloFilter implements Filter{
    /**
     * 请求过滤
     * @param servletRequest
     * @param servletResponse
     * @param filterChain
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //请求过程中执行
        System.out.println("我拦截到你了");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
        //响应给浏览器的过程中执行
        System.out.println("回去吧");
    }
}
